package com.zm.mybatis.damai.mapper;

import com.zm.mybatis.damai.bean.OrderItem;
import com.zm.mybatis.damai.bean.Orders;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

public interface OrderItemMapper {
    @Select("select * from dm_orderitem where id = #{ id }")
    @Results(id = "rm1",
            value = {
                    @Result(column = "id", property = "id", id = true),
                    @Result(column = "oid", property = "oid"),
                    @Result(column = "oid", property = "orders" ,
                            one = @One(
                                    select = "com.zm.mybatis.damai.mapper.OrdersMapper.selectById",
                                    fetchType = FetchType.EAGER
                            )
                    )


            }
    )
    OrderItem selectById(int id);

    OrderItem selectById1(int id);

    OrderItem selectById2(int id);

    List<OrderItem> selectByOid(int oid);

    Integer insert(OrderItem orderItem);

}
